package com.woniuxy.entity;

import org.apache.shiro.crypto.hash.Hash;

import java.util.HashMap;

/**
 * @Author: 马宇航
 * @Do: 统一响应体对象
 * @DateTime: 22/05/19/0019 下午 3:10
 * @Component: 成都蜗牛学苑
 **/
public class ResponseEntity extends HashMap {
    private final String CODE="code";//当做map中的key
    private final String MSG="msg";
    private final String OBJ = "data";
    public ResponseEntity(){

    }
    public ResponseEntity(Object obj) {
        super.put(CODE, 200);
        super.put(MSG,"执行成功");
        super.put(OBJ,obj);
    }
    public ResponseEntity(int code, String message ){
        super.put(CODE,code);
        super.put(MSG,message);
    }
    public ResponseEntity(int code, String message, Object data) {
        super.put(CODE,code);
        super.put(MSG,message);
        if (data != null) {
            super.put(OBJ,data);
        }
    }

    public static final ResponseEntity SUCCESS=new ResponseEntity(200,"执行成功！");
    public static final ResponseEntity ERROR=new ResponseEntity(500,"执行失败！");

    public ResponseEntity putKey(String key,Object obj){
        super.put(key,obj);
      return  this;
    }
}
